// 导入组件
// import VHome from '@/views/Home'
// import VLogin from '@/views/Login'
// import VRegister from '@/views/Register'
// import VSearch from '@/views/Search'
// import VTest from '@/views/Test'
// import VDetail from '@/views/GoodsDetail'
// import AddCartSuccess from '@/views/AddCartSuccess'
// import ShopCart from '@/views/ShopCart'
// import VTrade from '@/views/Trade'
// import VPay from '@/views/Pay'
// import PaySuccess from '@/views/PaySuccess'
// import OrderCenter from '@/views/Center'
// 配置路由懒加载
const VHome = () => import('@/views/Home')
const VLogin = () => import('@/views/Login')
const VRegister = () => import('@/views/Register')
const VSearch = () => import('@/views/Search')
const VTest = () => import('@/views/Test')
const VDetail = () => import('@/views/GoodsDetail')
const AddCartSuccess = () => import('@/views/AddCartSuccess')
const ShopCart = () => import('@/views/ShopCart')
const VTrade = () => import('@/views/Trade')
const VPay = () => import('@/views/Pay')
const PaySuccess = () => import('@/views/PaySuccess')
const OrderCenter = () => import('@/views/Center')
// 配置组件路由
const routes = [
  { path: '/', redirect: '/home' },
  { path: '/home', component: VHome },
  {
    path: '/login',
    component: VLogin,
    meta: {
      hiddenFooter: true
    }
  },
  {
    path: '/register',
    component: VRegister,
    meta: {
      hiddenFooter: true
    }
  },
  { path: '/search', component: VSearch },
  // 测试路由
  { path: '/test', component: VTest },
  // 商品详情路由
  { path: '/goodsdetail/:id', component: VDetail },
  // 添加购物车成功路由
  { path: '/addcartsuccess', component: AddCartSuccess },
  // 购物车路由
  { path: '/shopcart', component: ShopCart },
  // 订单详情路由
  { path: '/trade', component: VTrade },
  // 支付订单路由
  {
    path: '/pay',
    component: VPay,
    beforeEnter(to, from, next) {
      if (from.path === '/trade') {
        next()
      } else {
        next('/')
      }
    }
  },
  // 支付订单成功路由
  {
    path: '/paysuccess',
    component: PaySuccess,
    beforeEnter(to, from, next) {
      if (from.path === '/pay') {
        next()
      } else {
        next('/')
      }
    }
  },
  // 订单列表路由
  { path: '/ordercenter', component: OrderCenter }
]
export default routes
